﻿using FarmSmartSleep.Common.Domain.BeginTable;
using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Common.Infrastructure;
using MediatR;

namespace FarmSmartSleep.Organ.API.Application.SleepInfoCommands.RecordCommands
{
    public class GetCodeHandler : IRequestHandler<GetCodeCommand, Result>
    {
        private readonly IBaseRepository<SleepInfor> sleepbaseRepository;

        public GetCodeHandler(IBaseRepository<SleepInfor> sleepbaseRepository)
        {
            this.sleepbaseRepository = sleepbaseRepository;
        }
        //查询父母耳号
        public async Task<Result> Handle(GetCodeCommand request, CancellationToken cancellationToken)
        {
            var result= new Result() { Code=(int)CodeEnum.search};
            var list= sleepbaseRepository.GetAll().Where(x=>x.EarNumber==request.code).FirstOrDefault();
            result.Data = list;
            return result;
        }
    }
}
